package cn.xeblog.server.forward;

import cn.xeblog.forward.entity.Message;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author eleven
 * @date 2024/12/16 10:08
 * @apiNote
 */
@Slf4j
public class ForwardClientChannelAdapter extends SimpleChannelInboundHandler<Message> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Message message) throws Exception {
        log.info("收到服务端的消息：{}", message);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        ctx.writeAndFlush(Message.heartbeat());
    }
}
